﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Management/manage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Management_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <script type="text/javascript" src="<%=ResolveUrl("~/Scripts/jquery.utility.yu.js") %>"></script>
    <script language="javascript" type="text/javascript">
        $(function () {

            $("#txtPassword").focus();
            //回车提交
            $("#txtPassword").keydown(function (e) {
                if (e.which == 13) {
                    e.preventDefault();
                    var txtbox = $(this);
                    txtbox.blur();

                    var request = $.ajax({
                        url: '<%=ResolveUrl("~/handlers/LoginHandler.ashx") %>',
                        type: "POST",
                        data: { name: "Admin", pwd: $.trim($(this).val()) },
                        dataType: "json",
                        success: function (data) {
                            if (data.errcode == 0) {
                                if ($.utility.getPara("url") != "") {
                                    window.location.href = $.utility.getPara("url");
                                }
                                else {
                                    window.location.href = '<%=ResolveUrl("~/Management/Products/List.aspx") %>';
                                }
                            }
                            else {
                                alert("帐户错误。请重试...");
                                txtbox.focus();
                            }
                        },
                        error: function (jqXHR, textStatus) {
                            alert("登录错误。请重试...");
                        }
                    });
                }
            });
        });
        
    </script>
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true" AsyncPostBackTimeout="36000">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <h2 class="clearfix">
                <span class="float_l">登录</span>
            </h2>
            <asp:Panel ID="login" runat="server" class="login">
                <p><img src="../images/management/admin.jpg" /></p>
                <p><input id="txtPassword" type="password" /></p>
                <p class="error"></p>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

